package day2;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

//测试输入流
public class TestInput {
    public static void main(String[] args) throws IOException {
        File f = new File("d://IO//target.txt");
        if (f.exists()) {
            FileInputStream fis = new FileInputStream(f);
            //read() 运行一次读取一个字节
            //65-90:A-Z 97-122:a-z  48-57:1-9
            //int n = fis.read();
            //System.out.println(n);
            //n = fis.read();
            //System.out.println(n);
            //f.length() 获取文件的总字节数 返回long
            // for (int i = 0; i < f.length(); i++) {
            // int n = fis.read();
            // System.out.print(n+" ");
            //   }
            //read(字节数组):读取内容 存入到数组中 返回长度
            byte[] bs = new byte[10];
            int len = 0;
            //判断为 字节数组是否一次性读满
            while ((len = fis.read(bs)) != -1){
                //将字节数组 转换成字符串
                System.out.println(new String(bs,0,len));
            }
            fis.close();
        }else {
            System.out.println("文件不存在");
        }
    }
}
